﻿using System;
using System.Net;
using System.Web.Hosting;

//自定义命名空间
using DreamCube.Foundation.Basic.Objects.Log;

namespace DreamCube.Apps.WinForm.Common.DotNetWebServer
{
    public class AspNetHost : MarshalByRefObject
    {
        #region "私有字段"

        /// <summary>
        /// AspNet服务器对象
        /// </summary>
        private AspNetServer server = null;

        #endregion

        #region "实例方法"

        public AspNetHost()
        { }

        /// <summary>
        /// 开始处理请求
        /// </summary>
        public void StartProcessRequest(String[] prefix, String virtualPath, String physicalPath,
                                String[] defaultDocuments, String[] restrictedPaths)
        {
            try
            {
                this.server = new AspNetServer(prefix, virtualPath, physicalPath, defaultDocuments, restrictedPaths);
                this.server.Start();
            }
            catch (Exception ex)
            {
                LoggerManager.Logger.MakeLogAsync(ex);
            }
        }

        /// <summary>
        /// 程序域生命期最长
        /// </summary>
        /// <returns></returns>
        public override Object InitializeLifetimeService()
        {
            return null;
        }

        #endregion
    }
}
